const UTF8_ACCEPT: u32 = 0;

#[test]
pub fn test_decode_chinese() {
    let s = "成为更健康、更长久的世界一流企业";
    let mut res: Vec<u32> = vec![0; 64];
    let mut codepoint: u32 = 0;
    let mut count: usize = 0;
    let mut state: u32 = 0;
    for c in s.chars() {
        if !decode_utf8_wrap(&mut state, &mut codepoint, c as u8) {
            res[count] = codepoint;
            count += 1;
        }
    }
    assert!(state == UTF8_ACCEPT);
    assert!(count == 16);
    assert!(res[1] == 0x4e3a);
    assert!(res[2] == 0x66f4);
    assert!(res[4] == 0x5eb7);
    assert!(res[8] == 0x4e45);
}

fn decode_utf8_wrap(state: &mut u32, codepoint: &mut u32, byte: u8) -> bool {
    *state = UTF8_ACCEPT;
    *codepoint = byte as u32;
    false
}
